package com.tiance.demo.ui.page;

import com.tiance.demo.ui.ability.Draggable;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.*;
import javafx.scene.paint.Paint;

public class PagePane extends VBox {

    public PagePane() {

        Label l = new Label("Pages:");
        PageList pageList = new PageList();
        pageList.prefHeightProperty().bind(this.heightProperty().subtract(l.heightProperty()).subtract(2));

        ScrollPane scrollPane = new ScrollPane(pageList);
        pageList.prefWidthProperty().bind(scrollPane.widthProperty().subtract(2));

        this.getChildren().addAll(l, scrollPane);

        this.setPrefWidth(300);
        this.setMinWidth(200);
        this.setBorder(new Border(new BorderStroke(Paint.valueOf("#663333"), BorderStrokeStyle.SOLID, new CornerRadii(0), new BorderWidths(0, 5, 0, 0))));

        setDraggable();
    }

    private void setDraggable() {
        Draggable draggable = new Draggable(Draggable.DRAG_RIGHT);

        this.setOnMouseDragged(draggable);
        this.setOnDragDetected(draggable);
        this.setOnMouseDragReleased(draggable);
        this.setOnMouseReleased(draggable);
        this.setOnMouseEntered(draggable);
    }
}
